package com.riaevolution.components
{
	import mx.controls.Button;
	import mx.controls.ToggleButtonBar;
	import mx.core.ClassFactory;
	import mx.core.mx_internal;

	public class MultilineToggleButtonBar extends ToggleButtonBar
	{
		public function MultilineToggleButtonBar()
		{
			super();
			mx_internal::navItemFactory = new ClassFactory (MultilineButton);
		}
		
		private var previousSelected:Button;
		private var previousStyleName:Object;
		
		override protected function hiliteSelectedNavItem(index:int):void {
			super.hiliteSelectedNavItem(index);
			if (index > -1)
        	{
				// Hilite the new selection
				var child:Button = Button(getChildAt(selectedIndex));
				if(previousSelected && child != previousSelected) {
					child.styleName = previousStyleName;
				}
				previousSelected = child;
				previousStyleName = previousSelected.styleName;
            	child.styleName = "MultilineToggleButtonBarButtonSelected";
            	child.invalidateDisplayList();
        	}			
		}
	}
}